package com.eascs.ticket.ticket.controller;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.eascs.app.dao.PageResult;
import com.eascs.common.util.StringUtil;
import com.eascs.site.page.PaginationInfo;
import com.eascs.site.view.ViewContext;
import com.eascs.site.view.button.Button;
import com.eascs.site.view.button.ButtonHelper;
import com.eascs.ticket.common.controller.BaseMasterViewController;
import com.eascs.ticket.ticket.form.TicketSearchForm;
import com.eascs.ticket.ticket.vo.OrderByConstant;

@Controller
public class TicketReleaseNoteViewController extends BaseMasterViewController {

	@Inject
	private TicketSearchComponent ticketSearchComponent;

	@RequestMapping(path = "/ticket/releaseNote/findTicketView")
	public String findTicketView(TicketSearchForm ticketSearchForm) {
		if (StringUtil.isEmpty(ticketSearchForm.getOrderBy())) {
			ticketSearchForm.setOrderBy(OrderByConstant.ORDER_BY_VERSION);
		}
		PageResult<Object[]> pageResult = ticketSearchComponent.searchTicket(ticketSearchForm, "sql.TicketReleaseNoteRestController.findTicket");
		PaginationInfo paginationInfo = ticketSearchComponent.buildPaginationInfo(ticketSearchForm, pageResult);
		paginationInfo.setMoreButtons(new Button[] { ButtonHelper.createAjaxButton("查看", "/ticket/releaseNote/viewTicketReleaseNote?ticketId=") });
		ViewContext.put("paginationInfo", paginationInfo);
		ViewContext.put("ticketSearchForm", ticketSearchForm);

		return "/ticket/view/search";
	}
}
